#ifndef SERVER_H
#define SERVER_H

#include <QObject>
//#include <QJsonObject>
#include "Json/cJSON.h"
#include <qnetworkaccessmanager.h>
#include <QNetworkReply>
#include <QByteArray>
#include <QXmlStreamReader>
#include <QDebug>

#include "hereyou/soapH.h"
#include "hereyou/soapStub.h"

#include "ctrlinfo.h"
#include "cabinetconfig.h"

class server : public QObject
{
    Q_OBJECT
public:
    explicit server(QObject *parent = NULL);
    void setServerAddress(QString address);
    void test();

private:
    QNetworkAccessManager* manager;
    QNetworkReply* reply_goods_fetch;
    CabinetConfig* config;
    ctrlInfo* info;
    QDateTime curTime;
    QByteArray serverAddress;

    QByteArray xml_fetch_goods(QString departId, QString userId, QString goodsId);
    void recv_goods_fetch(QByteArray qba, QDateTime curT);
//    QJsonValue getJsonValue(QJsonObject object, QString key);

    QDateTime getServerTime(QString sTime);
    QByteArray readXmlRst(QByteArray rst);

private slots:
    void recv_goods_fetch();

signals:
    void fetch_goods_rst(QString msg);
    void new_report(ctrlInfo* info);

public slots:
    void fetchGoods(QString departId, QString userId, QString goodsId);
};

#endif // SERVER_H
